package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.common.domain.query.PageQuery;
import com.tianji.learning.domain.dto.QuestionFormDTO;
import com.tianji.learning.domain.po.InteractionQuestion;
import com.tianji.learning.domain.query.QuestionPageQuery;
import com.tianji.learning.domain.vo.QuestionVO;
import com.tianji.learning.service.IInteractionQuestionService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 互动提问的问题表 前端控制器
 * </p>
 *
 * @author 陈宽
 * @since 2025-07-02
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/questions")
public class InteractionQuestionController {
    private final IInteractionQuestionService questionService;
    @PostMapping
    public void addQuestion(@RequestBody QuestionFormDTO questionDTO) {
        questionService.addQuestion(questionDTO);
    }
    @PutMapping("{id}")
    public void updateQuestion(@PathVariable("id") Long id, @RequestBody QuestionFormDTO questionDTO) {
        questionService.updateQuestion(id, questionDTO);
    }
    @DeleteMapping("{id}")
    public void deleteQuestion(@PathVariable("id") Long id) {
        questionService.deleteById(id);
    }
    @GetMapping("page")
    public PageDTO<QuestionVO> queryQuestions(QuestionPageQuery query) {
        return questionService.questionPage(query);
    }
    @GetMapping("{id}")
    public QuestionVO queryQuestionById(@PathVariable("id") Long id) {
        return questionService.getVoById(id);
    }
}
